#ifndef CAPTURER_H
#define CAPTURER_H

#include <QObject>
#include <Windows.h>
#include "KeyMonitor.h"
#include "KeyLaunch.h"
#include <QJsonObject>
#include <QJsonArray>

class DesignBLL;

/*捕获器*/

class KeyCapturer : public QObject
{
    Q_OBJECT

public:
    virtual ~KeyCapturer();
    static KeyCapturer *&instance()
    {
        static KeyCapturer *s = nullptr;
        if (s == nullptr)
        {
            s = new KeyCapturer();
        }
        return s;
    }

public:
    bool hookKeyValue(KBDLLHOOKSTRUCT *key);
    void addDesignBLL(DesignBLL *designBLL);

    void read(const QJsonObject &json);
    void write(QJsonObject &json) const;

    bool loadKeyCapturer();
    bool saveKeyCapturer() const;

protected:
    KeyCapturer();

private:
    QList<QList<QObject *> *> dataLists;
    QList<DesignBLL * > designBLLLists;

    KeyLaunch *keyLaunch;
};
#endif // CAPTURER_H
